<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">母托编码</label>
        <el-input v-model.trim="query.parentPalletCode" clearable placeholder="母托编码" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" @clear="crud.toQuery" />
        <label class="el-form-item-label">入库port口</label>
        <el-input v-model.trim="query.portLocation" clearable placeholder="入库port口" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" @clear="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <crudOperation :permission="permission" />
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column prop="parentPalletCode" label="母托编码" />
        <el-table-column prop="parentPalletType" label="母托类型">
          <template slot-scope="scope">
            {{ dict.label.parentPallet_Type[scope.row.parentPalletType] }}
          </template>
        </el-table-column>
        <!-- <el-table-column prop="stackOrder" label="堆叠顺序" /> -->
        <el-table-column prop="status" label="母托状态">
          <template slot-scope="scope">
            {{ dict.label.pallet_status[scope.row.status] }}
          </template>
        </el-table-column>
        <el-table-column prop="portLocation" label="入库port口" />
        <el-table-column prop="storageCode" label="储位编码" />
        <el-table-column prop="useRate" label="母托使用率">
          <template slot-scope="scope">
            {{ scope.row.useRate ? (scope.row.useRate * 100).toFixed(2) + '%' : '' }}
          </template>
        </el-table-column>
        <el-table-column prop="updateTime" label="更新时间" />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudParentPallet from '@/api/work/parentPallet'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import crudOperation from '@crud/CRUD.operation'

const defaultForm = { id: null, parentPalletCode: null, parentPalletType: null, stackOrder: null, portLocation: null, status: null, parentPalletDescription: null, storageId: null, lengthPallet: null, widePallet: null }
export default {
  name: 'ParentPallet',
  components: { pagination, rrOperation, crudOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['parentPallet_Type', 'pallet_status'],
  cruds() {
    return CRUD({ title: 'parentPallet', url: 'api/parentPallet', idField: 'id', sort: 'id,desc', crudMethod: { ...crudParentPallet },
      optShow: {
        add: false,
        del: false,
        edit: false,
        reset: true,
        download: true
      }
    })
  },
  data() {
    return {
      permission: {
        add: ['admin', 'parentPallet:add', 'otherUser'],
        edit: ['admin', 'parentPallet:edit', 'otherUser'],
        del: ['admin', 'parentPallet:del', 'otherUser']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'parentPalletCode', display_name: '母托编码' }
      ]
    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
